package com.heishitech.face.config;

import com.baidu.aip.face.AipFace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author Sheeper
 * @date 2017/10/25.
 */
@Configuration
public class AipClientConfig {
    private Logger logger = LoggerFactory.getLogger(AipClientConfig.class);

    @Value("${aip.appId}")
    private String APP_ID;

    @Value("${aip.apiKey}")
    private String API_KEY;

    @Value("${aip.secretKet}")
    private String SECRET_KEY;

    @Bean(name = "aipClient")   //声明其为Bean实例
    @Primary
    public AipFace aipFace() {
        AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);
        client.setConnectionTimeoutInMillis(5000);
        client.setSocketTimeoutInMillis(5000);
        logger.info("生成一个aipClient");
        return client;
    }
}
